* Takes doctor IDs treating AMI patients in each year of sample

clear all
set more off
pause on

forval year=2005(1)2017{
use "$savedata/ami_`year'", clear
keep if ami==1
keep if finyear==`year'

keep if tretspef=="320"
gen cardio_cons = 1
collapse (max) cardio_cons, by(pconsult finyear)

tempfile c`year'
save `c`year''

}

use "`c2005'", clear

forval year=2006(1)2017{
append using "`c`year''"
}

collapse (sum) num_years = cardio_cons (max) cardio_cons last_year = finyear (min) first_year = finyear, by(pconsult)

save "$savedata/cardiologist_list_0517.dta", replace
